<? if (!defined("BASEPATH")) exit("No direct script access allowed");

echo	"<h3>".$this->lang->line("FIND_YOUR_STUDY_ABROAD_PROGRAMME_BY")."</h3>";

$searchCriterias = array();
if(isset($PROGTYPE) and isset($PROGTYPE["PROGTYPE"])) {
	$searchCriterias[] = "PROGRAM_TYPE";
}
if(count($getCountry)) {
	$searchCriterias[] = "COUNTRY";
}
if(count($getSubject)) {
	$searchCriterias[] = "SUBJECT";
}
if(isset($getGradeLevel)) {
	$searchCriterias[] = "GRADE_LEVEL";
}
if(isset($getLanguage)) {
	$searchCriterias[] = "LANGUAGE";
}

echo	"<div class=\"accordion\">";
foreach($searchCriterias as $criteria) {
	echo		"<article class=\"box\">";
	echo			"<header>";
	echo				"<h3>".$this->lang->line($criteria)."</h3>";
	echo			"</header>";
	echo			"<section class=\"wide\">";
	switch($criteria) {
		case "PROGRAM_TYPE": {
			echo				"<ul class=\"\">";
			foreach($PROGTYPE["PROGTYPE"] as $sname => $lname) {
				echo					"<li style=\"background: none; width:100%;\">".form_checkbox(array("name" => "program_type[]", "id" => "program_type_".$sname, "value" => $sname, "checked" => in_array($sname, (($this->input->post("program_type"))?($this->input->post("program_type")):(array())))))." ".form_label($lname, "program_type_".$sname)."</li>";
			}
			echo				"</ul>";
		} break;
		
		case "COUNTRY": {
			if(count($getCountry)) {
				$conName = "";
				foreach($getCountry as $ii => $cou) {
					if($conName != $cou["conName"]) {
						if($ii) {
							echo				"</ul>";
						}
						echo				"<h3>".$cou["conName"]."</h3>";
						echo				"<ul class=\"multicol colnum2\">";
						$conName = $cou["conName"];
					}
					echo					"<li style=\"background: none;\">".form_checkbox(array("name" => "cou[]", "id" => "cou_".$cou["couId"], "value" => $cou["couId"], "checked" => in_array($cou["couId"], (($this->input->post("cou"))?($this->input->post("cou")):(array())))))." ".form_label($cou["couName"]." (".$cou["majCnt"].")", "cou_".$cou["couId"])."</li>";
				}
				echo				"</ul>";
			}
		} break;
		
		case "SUBJECT": {
			if(count($getSubject)) {
				foreach($getSubject as $ii => $sub) {
					if(isset($sub["children"])) {
						echo				"<h3>".$sub["subName"]."</h3>";
						echo				"<ul class=\"multicol colnum2\">";
						foreach($sub["children"] as $child_sub) {
							echo					"<li style=\"background: none; width: 270px;\">".form_checkbox(array("name" => "sub[]", "id" => "sub_".$child_sub["subId"], "value" => $child_sub["subId"], "checked" => in_array($child_sub["subId"], (($this->input->post("sub"))?($this->input->post("sub")):(array()))) ))." ".form_label($child_sub["subName"]." (".$child_sub["majCnt"].")", "sub_".$child_sub["subId"])."</li>";
						}
						echo				"</ul>";
					}
				}
			}
		} break;
		
		case "GRADE_LEVEL": {
			if(isset($getGradeLevel)) {
				echo				"<ul class=\"\">";
				foreach($getGradeLevel as $ii => $grade_level) {
					echo					"<li style=\"background: none; width:100%;\">".form_checkbox(array("name" => "grade_level[]", "id" => "grade_level_".$ii, "value" => $grade_level, "checked" => in_array($grade_level, (($this->input->post("grade_level"))?($this->input->post("grade_level")):(array())))))." ".form_label($grade_level, "grade_level_".$ii)."</li>";
				}
				echo				"</ul>";
			}
		} break;
		
		case "LANGUAGE":  {
			if(isset($getLanguage)) {
				echo				"<ul class=\"\">";
				foreach($getLanguage as $ii => $language) {
					echo					"<li style=\"background: none; width:100%;\">".form_checkbox(array("name" => "language[]", "id" => "language_".$ii, "value" => $language, "checked" => in_array($language, (($this->input->post("language"))?($this->input->post("language")):(array())))))." ".form_label($language, "language_".$ii)."</li>";
				}
				echo				"</ul>";
			}
		} break;
	}
	echo			"</section>";
	echo		"</article>";
}
echo	"</div>";

echo	"<p class=\"fl\"><br/>".anchor("advanced_search/new", $this->lang->line("DELETE_CURRENT_SEARCH_CRITERIAS"))."</p>";
echo	"<p class=\"fr\">".form_input(array("type" => "submit", "class" => "button", "id" => "advancedSearchButton", "value" => $this->lang->line("SEARCH")))."</p>";
echo	"<br class=\"cb\" />";